<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
   
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
    <link rel="stylesheet" href="../css/newEnvsion.css" type="text/css" />
	<link rel="stylesheet" type="text/css" href="../extjs/resources/css/ext-all.css">	
    <script type="text/javascript" src="../extjs/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="../extjs/ext-all-debug.js"></script>
    
    
    <script type="text/javascript">
    	Ext.onReady(function(){
    		var changepwd = new Ext.form.FormPanel({
				id:'changepwd',
				defaultType:'textfield',
				labelAlign:'right',
				labelWidth:60,
				frame:true,
				defaults:{
					allowBlank:false
				},
				items:[
				
				{id:'oldpwd',name:'oldpwd',fieldLabel:'原密码',blankText:'不能为空',inputType:'password',anchor:'98%',maxLength:10},
				{id:'newpwd1',fieldLabel:'新密码',blankText:'不能为空',inputType:'password',anchor:'98%',maxLength:10},
				{id:'newpwd2',name:'newpwd',fieldLabel:'确认密码',blankText:'不能为空',anchor:'98%',inputType:'password'}
				
				]		
			});
    		var win = new Ext.Window({
    			title:'修改密码',
    			id:'changpwdForm',
    			
				
    			closable:true,
				collapsible:false,
				resizable:false,
				defaults:{
					border:false
				},
				buttonAlign:'center',
				buttons:[
				{text:'确定',type:'submit',id:'sb',height:100,handler:changepwd1},
				{text:'重置',height:100,handler:function(){
					Ext.getCmp('changepwd').form.reset();
				}}	
				],
				items:[
					changepwd
				]
    		});
    		win.show();
		});
		
		function changepwd1(){
			
			var loginForm = Ext.getCmp("changepwd");
			var pas1 = Ext.getCmp("newpwd1").getValue();
			var pas2 = Ext.getCmp("newpwd2").getValue();
			var oldpwd = Ext.getCmp("oldpwd").getValue();
			var pasfilter = /^.{6,}$/
			if(!pasfilter.test(pas1)){
				Ext.Msg.alert("密码长度大于6位，由字母，数字，常用符号组成");
			}
			if(pas1 != pas2){
				Ext.Msg.alert("两次密码不同");
				return;
			} 
			Ext.Ajax.request({
				url:'login/changepwd.action',
				params:{
					oldpwd:oldpwd,newpwd:pas2
				},
				success:function(response,options){
					var responseArray = Ext.util.JSON.decode(response.responseText); 
					if(responseArray.msg == "ERROR"){
						alert('原密码不正确');
						return;
					}  
					if(responseArray.msg == "OK"){
						alert("修改成功!");
						history.go(-1);
					}
				}
			});
			
			
			
		}
    	
    </script>
  </head>
  
  <body>
  <div id="wrap">
  	<div id="main">
  	</div>
  </div>
  </body>
</html>